#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <vector>
#include "Consuption.h"
#include "Production.h"

int main(){		

	Production production;
	production.init();	

	//Vectores de estado
	std::vector<ProductionState> productionStates;
	productionStates.push_back(production.getState());

	std::string in;
	bool wantToExit = false;
	bool bIsConsuptionSet = false;
	int iMAX = 2;
	int iMIN = -1;
	srand((unsigned) time(0));

	do{		
		
		//if(!bIsConsuptionSet){
		//int iRandomConsuption = ((rand() / iMAX) * iMAX + iMIN );
		//	int iRandomConsuption = iMIN + rand() % (iMAX - iMIN);
		//production.setConsuption(production.getConsuption() + iRandomConsuption);		
		//bIsConsuptionSet = true;
		//}

		std::cout << production.toString();
		std::cout << "\n\n";
		char cOption = 0;
		double dValue;
		std::cout << "Press 't' to advance turn. \n";
		std::cin >> cOption;

		if(cOption != 't'){
			std::cout << "Value? >> ";
			std::cin >> dValue;

			switch(cOption){
				case 'c':
					production.setConsuption(dValue);
					break;
				case 'e':
					production.setExportation(dValue);
					break;
				case 'n':
					production.setNp(dValue);
					break;
				case 'p':
					production.setCp(dValue);
					break;
				case 'i':
					production.setNi(dValue);
					break;
				case 'm':
					production.setCi(dValue);
					break;						
				case '1':
					production.setIb(dValue);
					break;
				case '2':
					production.setIi(dValue);
					break;
				case 'z':
					production.saveStateMoney(dValue);
					break;
				case 'x':
					wantToExit = true;
					break;
				default:
					std::cout << "\nUnknown option." << std::endl;
			}
		}
		else{
			production.update();
			productionStates.push_back(production.getState());
			bIsConsuptionSet = false;
		}
		

	}while(!wantToExit);

	production.release();

	return 0;
}
